<template>
	<div class="achievement">
		<div class="classIndex_h">
			<span>学生成绩</span>
		</div>
		<!--  -->
		<div class="classNotice_search clear">
			<div class="achievement_type fl">
				<router-link :to="{path: '/class/achieve/list', query: {id: path}}">
					我发布的
				</router-link>
				<router-link :to="{path: '/class/achieve/class', query:{id: path}}">
					班级成绩
				</router-link>
			</div>
		</div>
		<div v-loading="loading" v-show="!placeholder">
			<template>
				<el-table :data="AchievementList" border style="width: 100%">
					<el-table-column prop="name" label="任务名称" show-overflow-tooltip>
					</el-table-column>
					<el-table-column prop="_status" label="状态" width="80" align="center" show-overflow-tooltip>
					</el-table-column>
					<el-table-column width="180" align="center" prop="create_time" label="发布时间">
					</el-table-column show-overflow-tooltip>
					<el-table-column align="center" label="操作" width="80">
						<template slot-scope="scope">
							<router-link :to="{path:'/class/achieve/detail',query: {id: path, aid: scope.row.id}}">详情</router-link>
						</template>
					</el-table-column>
				</el-table>
			</template>
		</div>
		<div class="pageBox" v-if="total_number > page_size">
			<el-pagination @current-change="change_page" :page-size="page_size" :current-page="page_index" layout="prev, pager, next" :total="total_number">
			</el-pagination>
		</div>
		<div class="dependent" v-if="placeholder">
			<i class="ipm image_nofound"></i>
			<p>还没发现任何相关的内容哦~</p>
		</div>
	</div>
</template>
<script>
export default {
	name: '',
	data() {
		return {
			path: this.$route.query.id,
			searchVal: '',
			AchievementList: [],
			page_index: 1,
			page_size: this.$g.page_size,
			total_number: 0,
			placeholder: false,
			loading: true
		}
	},
	created() {

	},
	watch: {
		'$store.state.changData': {
			handler(val, newval) {
				this.path = sessionStorage.getItem('classId')
				this.getAchievementList(2)
			},
			immediate: true
		}
	},
	computed: {

	},
	methods: {
		getAchievementList(type) {

			let success = (res => {
				let data = res.data;
				this.AchievementList = data.data;
				this.page_index = parseInt(data.page_index);
				this.total_number = data.data_sum;

				this.loading = false;
				this.placeholder = this.AchievementList.length === 0 ? true : false
			});

			let fail = (res => { console.log(res); })
			this.$ajax({
				url: 'api/org/class_something',
				method: 'get',
				params: {
					classid: this.path,
					page: this.page_index,
					size: this.page_size,
					style: 6,
					create_id: this.$g.user_id,
					type: '1,2,3',
					data_type: 2
				},
				func: { success: success, fail: fail }
			})
		},
		//查看已读情况
		readS() {
			this.readSituation = true;
		},
		change_page(val) {
			this.page_index = val;
			this.getAchievementList()
		}
	}
}
</script>